# Maintainer: Some One <some.one@some.email.com>

_realname=spdylay
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.4.0
_pkgver=v$pkgver
pkgrel=1
pkgdesc="The experimental SPDY protocol version 2, 3 and 3.1 implementation in C (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://tatsuhiro-t.github.io/spdylay/"
license=('MIT')
source=("spdylay-${pkgver}.tar.gz::https://github.com/tatsuhiro-t/spdylay/releases/download/${_pkgver}/spdylay-${pkgver}.tar.gz"
         spdylay-1.4.0-fix-zlib.patch)
sha256sums=('f45641df48f0f8e13fe80166437828201b46f56681b11cd93a614a82ebd5dcba'
            'a5d3f3be9ad333771c61aa11dfc18dcd0670bb76fe401493fb1ecb80a5d1217f')

prepare() {
  cd $srcdir/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/spdylay-1.4.0-fix-zlib.patch
}

build() {
  cd "$srcdir"/${_realname}-${pkgver}
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared \
    --enable-src=no \
    --enable-examples=no
  make
}

chec() {
  ${srcdir}/build-${CARCH}
  make test
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"
}
